home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DESQVIEW.SWG / 0002_DETCTWIN.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  5KB  |  234 lines

  1. {
  2. Here's a little something that will detect Desqview and Windows ...
  3. }
  4. Unit DESQVIEW ;
  5. {$O+,F+}
  6.  
  7. Interface
  8. Uses Dos, Crt;
  9.  
  10. Var
  11.   DV_ACTIVE    : Boolean ;          { True if running under DESQview     }
  12.   Win_ACTIVE   : Boolean ;          { True if Windows 3.x Enhanced Mode  }
  13.   DV_VERSION   : Word ;             { desqVIEW version number            }
  14.   DV_VSEG      : Word ;
  15.   DV_VMODE     : Byte Absolute $0040:$0049 ;
  16.   DV_VWIDTH    : Byte ;
  17.   DV_VROWS     : Byte ;
  18.   DV_VofS      : Word ;
  19.  
  20.  
  21. Procedure DV_RQM   ;                { Give up the rest of our timeslice  }
  22. Procedure DV_begin_CRITICAL ;       { Turn Task Switching off.           }
  23. Procedure DV_end_CRITICAL ;         { Turn switching back on.            }
  24. Procedure DV_VIDEO_BUFFER ;         { Set Global Video Variables         }
  25. Function  DV_Window_NUMBER : Byte ; { Returns Window Number              }
  26. Procedure DV_COMMON_MEMorY(Var AVAIL, LARGEST, toTAL: Word) ;
  27. Procedure DV_CONV_MEMorY  (Var AVAIL, LARGEST, toTAL: Word) ;
  28. Procedure DV_EMS_MEMorY   (Var AVAIL, LARGEST, toTAL: Word) ;
  29. Procedure DV_FASTWrite    (X,Y: Word; STR: String; FG,BG: Word) ;
  30.  
  31. Implementation
  32.  
  33. Var
  34.   REG     : Registers ;
  35.  
  36. Procedure DV_RQM ;
  37.  
  38. begin
  39.   if DV_ACTIVE then begin
  40.     Asm
  41.       mov  ax, 1000h
  42.       int  15h
  43.     end ;
  44.   end else begin
  45.     if Win_ACTIVE then begin
  46.       Asm
  47.         mov  ax, 1680h
  48.         int  2fh
  49.       end ;
  50.     end ;
  51.   end ;
  52. end;
  53.  
  54. Procedure DV_begin_CRITICAL ;
  55.  
  56. begin
  57.   if DV_ACTIVE then begin
  58.     Asm
  59.       mov   ax, $101b
  60.       int   15h
  61.     end ;
  62.   end else begin
  63.     if Win_ACTIVE then begin
  64.       Asm
  65.         mov  ax, 1681h
  66.         int  2fh
  67.       end ;
  68.     end ;
  69.   end ;
  70. end ; { dv_begin_critical }
  71.  
  72. Procedure DV_end_CRITICAL ;
  73.  
  74. begin
  75.   if DV_ACTIVE then begin
  76.     Asm
  77.       mov   ax, $101c
  78.       int   15h
  79.     end ;
  80.   end else begin
  81.     if Win_ACTIVE then begin
  82.       Asm
  83.         mov  ax, $1682
  84.         int  2fh
  85.       end ;
  86.     end ;
  87.   end ;
  88. end ; { dv_end_critical }
  89.  
  90. Procedure DV_VIDEO_BUFFER ;
  91.  
  92. begin
  93.   if DV_ACTIVE then begin
  94.     Asm
  95.       mov  ax, $2b02
  96.       mov  bx, $4445  ; { DE }
  97.       mov  dx, $5351  ; { SQ }
  98.       int  21h
  99.       mov  DV_VSEG, dx
  100.       mov  DV_VWIDTH, bl
  101.       mov  DV_VROWS, bh
  102.       mov  DV_VofS, 0
  103.     end ;
  104.   end else begin
  105.     if (DV_VMODE = 7) then DV_VSEG := $b000 else DV_VSEG := $b800 ;
  106.     DV_VWIDTH := memw[$0040:$004a] ;
  107.     DV_VROWS  := 25 ;
  108.     DV_VofS   := memw[$0040:$004e] ;
  109.   end ;
  110. end ; { dv_video_buffer }
  111.  
  112. Function DV_Window_NUMBER ;
  113.  
  114. begin
  115.   if DV_ACTIVE then begin
  116.     Asm
  117.       mov   ax, $de07
  118.       int   15h
  119.       mov  @RESULT, al
  120.     end ;
  121.   end else begin
  122.     DV_Window_NUMBER := 0 ;
  123.   end ;
  124. end ;
  125.  
  126. Procedure DV_COMMON_MEMorY ;
  127.  
  128. begin
  129.   if DV_ACTIVE then begin
  130.     Asm
  131.       mov  ax, $de04
  132.       int  15h
  133.       les  di, AVAIL
  134.       mov  es:[di], bx
  135.       les  di, LARGEST
  136.       mov  es:[di], cx
  137.       les  di, toTAL
  138.       mov  es:[di], dx
  139.     end ;
  140.   end else begin
  141.     AVAIL := 0 ;
  142.     LARGEST := 0 ;
  143.     toTAL := 0 ;
  144.   end ;
  145. end ;
  146.  
  147. Procedure DV_CONV_MEMorY ;
  148.  
  149. begin
  150.   if DV_ACTIVE then begin
  151.     Asm
  152.       mov  ax, $de05
  153.       int  15h
  154.       les  di, AVAIL
  155.       mov  es:[di], bx
  156.       les  di, LARGEST
  157.       mov  es:[di], cx
  158.       les  di, toTAL
  159.       mov  es:[di], dx
  160.     end ;
  161.   end else begin
  162.     AVAIL := 0 ;
  163.     LARGEST := 0 ;
  164.     toTAL := 0 ;
  165.   end ;
  166. end ;
  167.  
  168. Procedure DV_EMS_MEMorY ;
  169.  
  170. begin
  171.   if DV_ACTIVE then begin
  172.     Asm
  173.       mov  ax, $de06
  174.       int  15h
  175.       les  di, AVAIL
  176.       mov  es:[di], bx
  177.       les  di, LARGEST
  178.       mov  es:[di], cx
  179.       les  di, toTAL
  180.       mov  es:[di], dx
  181.     end ;
  182.   end else begin
  183.     AVAIL := 0 ;
  184.     LARGEST := 0 ;
  185.     toTAL := 0 ;
  186.   end ;
  187. end ;
  188.  
  189. Procedure DV_FASTWrite ;
  190.  
  191. Var
  192.   I      : Word ;
  193.  
  194. begin
  195.   X := DV_VofS + ((Y-1) * DV_VWIDTH + (X-1)) * 2 ;
  196.   For I := 1 to length(STR) do begin
  197.     MEMW[DV_VSEG:X] := (((BG shl 4) + FG) shl 8) + ord(STR[I]) ;
  198.     X := X + 2 ;
  199.   end ;
  200. end ;
  201.  
  202. begin { main }
  203.   REG.AX := $2b01 ;
  204.   REG.CX := $4445 ;  { DE }
  205.   REG.DX := $5351 ;  { SQ }
  206.   intr($21,REG) ;
  207.  
  208.   Win_ACTIVE := False ;
  209.   DV_ACTIVE := (REG.AL <> $ff) ;
  210.  
  211.   DV_VERSION := 0 ;
  212.   if DV_ACTIVE then begin
  213.     DV_VERSION := REG.BX ;
  214.     REG.AX := $de0b ;
  215.     REG.BX := $0200 ;  { Minimum of Desqview 2.00 }
  216.     intr($15,REG) ;
  217.   end else begin
  218.     REG.AX := $1600 ;
  219.     intr($2f,REG) ;
  220.     Case REG.AL of
  221.       $00 : ; { An enhanced Windows API is not Running }
  222.       $80 : ; { An enhanced Windows API is not Running }
  223.       $01 : ; { Windows / 386 Version 2.x              }
  224.       $ff : ; { Windows / 386 Version 2.x              }
  225.       else begin
  226.         Win_ACTIVE := True ;
  227.         DV_VERSION := swap(REG.AX) ;
  228.       end ;
  229.     end ;
  230.   end ;
  231.  
  232.   DV_VIDEO_BUFFER ;
  233. end. { main }
  234.